package com.zxy.example.consumer;

import com.zxy.example.common.model.User;
import com.zxy.example.common.service.UserService;
import com.zxy.zxyrpc.model.ReferenceService;
import com.zxy.zxyrpc.proxy.ServiceProxyFactory;

/**
 * 消费者（RPC远程调用者）
 *
 * @author zxy
 * @since 2025/5/11
 **/
public class EasyConsumerExample {
    public static void main(String[] args) {
        // todo 需要获取 userService 的实现类对象
        // UserService userService = null;
        // UserService userService = new UserServiceProxy();
        UserService userService = ServiceProxyFactory.getProxy(UserService.class,new ReferenceService());

        User user = new User();
        user.setName("zxy yy-ds");
        User newUser = userService.getUser(user);
        if (newUser != null) {
            System.out.println(newUser.getName());
        } else {
            System.out.println("user == null");
        }
    }
}
